package com.example.user.myzzyl_android;

import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.support.v7.app.AppCompatActivity;
import android.widget.ImageView;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class MainActivity extends AppCompatActivity {
    Handler handler = new Handler();    //主要接受子线程发送的数据， 并用此数据配合主线程更新UI
    Runnable runnable = new Runnable() {    //实现多线程
        @Override
        public void run() {
            show();
        }
    };
    @BindView(R.id.iv_bg)
    ImageView ivBg;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        ButterKnife.bind(this);
        handler.postDelayed(runnable,3000);     //延迟3000毫秒后开始运行runnable对象
    }
    @OnClick(R.id.btn_show)
    public void onViewClicked(){
        handler.removeCallbacks(runnable);      //删除runnable对象,使线程停止运行
        show();
    }
    private void show(){
        startActivity(new Intent(this,DengLu.class));      //跳转到登陆页面
        finish();   //退出此界面（直到程序从新启动才打开次界面）
    }
}
